
<template>
  <div>
    <h2>登录页面</h2>
    用户名<input type="text" v-model="username">
    密码<input type="password" v-model="password">
    <button @click="sub">登录</button>
  </div>
</template>

<script>
export default {
  data(){
    return{
      username:'',
      password:''
    }
  },
  methods:{
    sub:function(){
      let data ={
        username:this.username,
        password:this.password
      };
      this.axios({
        url:'http://127.0.0.1:8000/login/',
        method:'post',
        data:data
      }).then(
        res=>{
          //存储信息
          localStorage.setItem('auth',res.data.data);
        alert('登录成功');
      },error=>{
        alert('登录失败');
      })
    }
  }
}
</script>

<style>

</style>
